from EmpVoting.Stat import BaseStatFromFieldCollection

class ExperimentStatFromNetworkField(BaseStatFromFieldCollection):

    def __init__(self, fieldName, statOp):
        '''
        Constructor
        
        Supported stat operations are: "mean", "std", "distribution", "min", "max", "list", "flat"
        '''
        
        self.FieldName = fieldName
        self.StatOp = statOp
        
    def Apply(self, expResult):
        statResult = self._CalcStatFromList(expResult.__dict__[self.FieldName], self.StatOp)
        expResult.__dict__[self.FieldName + "_" + self.StatOp] = statResult
        